GetMaxCompressionSize
TheGetMaxCompressionSize
function allows your application to determine the maximum size an image will be after compression. You specify the compression characteristics, including compression type and quality, along with the image.
pascal OSErr GetMaxCompressionSize (PixMapHandle src, const Rect *srcRect, short colorDepth, CodecQ quality, CodecType cType, CompressorComponent codec, long *size);
src
- Contains a handle to the source image. The source image must be stored in a pixel map structure. The compressor uses only the image's size and pixel depth to determine the maximum size of the compressed image.
srcRect
- Contains a pointer to a rectangle defining the portion of the source image that is to be compressed. You may set this parameter to
nil
if you are interested only in information about quality settings.GetCompressionTime
then uses the bounds of the source pixel map.colorDepth
Specifies the depth at which the image is to be compressed. If you set this parameter to 0, the Image Compression Manager determines the appropriate value for the source image. Values of 1, 2, 4, 8, 16, 24, and 32 indicate the number of bits per pixel for color images. Values of 34, 36, and 40 indicate 2-bit, 4-bit, and 8-bit grayscale, respectively, for grayscale images. Your program can determine which depths are supported by a given compressor by examining the compressor information structure returned by theGetCodecInfo
function (see "Getting Information About Compressor Components" on page 3-56 for more information on theGetCodecInfo
function).quality
- Specifies the desired compressed image quality. See "Compression Quality Constants" beginning on page 3-52 for valid values.
cType
- Specifies a compressor type. You must set this parameter to a valid compressor type (see Table 3-3 on page 3-59 for a list of the
available compressor types).codec
- Contains a compressor identifier. Specify a particular compressor by setting this parameter to its compressor identifier. Alternatively, you may use one of the special identifiers:
anyCodec
- Choose the first compressor of the specified type
bestSpeedCodec
- Choose the fastest compressor of the specified type
bestFidelityCodec
- Choose the most accurate compressor of the specified type
bestCompressionCodec
- Choose the compressor that produces the smallest resulting data
- You can also specify a component instance. This may be useful if you have previously set some parameter on a specific instance of a
codec
field and want to make sure that the specified instance is used for that operation.size
- Contains a pointer to a field to receive the size, in bytes, of the compressed image.
DESCRIPTION
The Image Compression Manager returns the maximum resulting size for the specified image and parameters. Your application may then use this information to allocate memory for the compression operation.RESULT CODES
noErr 0 No error paramErr -50 Invalid parameter specified noCodecErr -8961 The Image Compression Manager could not find the specified compressor